﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using WebKpiPage.Data.Common;
using Model;
namespace WebKpiPage.Data.XingNengMgr
{
    public class StatisZhibiao
    {
        public static DataTable GetZhibiaoStatis(XinNengStatisCodition codition){
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_统计各项性能指标]";
                int count = 4; 
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@时间", codition.StartTime);
                sp[--count] = new SqlParameter("@类型", codition.CompanyType);
                sp[--count] = new SqlParameter("@统计时间类型", codition.TimeType);
                sp[--count] = new SqlParameter("@地市id", codition.CityID);
               
               DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds.Tables[0];
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetZhibiaoStatis", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }

        #region mtsp_统计_问题点处理情况
        /// <summary>
        /// 统计_问题点处理情况
        /// </summary>
        /// <param name="cityName"></param>
        /// <returns></returns>
        public static DataTable GetAlarmStatisInfo(string cityName)
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_统计_问题点处理情况]";
                int count = 1;
                SqlParameter[] sp = new SqlParameter[count];
                sp[--count] = new SqlParameter("@地市", cityName);
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText, sp);
                return ds.Tables[0];
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetAlarmStatisInfo", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        #endregion

        #region mtsp_统计_问题点处理情况_各地市
        /// <summary>
        /// 统计_问题点处理情况_各地市
        /// </summary>
        /// <returns></returns>
        public static DataTable GetCityAlarmStatisInfo()
        {
            SqlConnection conn = ConnMng.GetConnection();
            if (conn == null || conn.State != System.Data.ConnectionState.Open)
            {
                return null;
            }
            try
            {
                string commandText = "MTNOH_GZ_APP.[dbo].[mtsp_统计_问题点处理情况_各地市]";
                DataSet ds = SqlHelper.ExecuteDataset(conn, CommandType.StoredProcedure, commandText);
                return ds.Tables[0];
            }
            catch (Exception e)
            {
                LogSystem.LogError("GetCityAlarmStatisInfo", e);
                return null;
            }
            finally
            {
                ConnMng.ReleaseConnection(conn);
            }
        }
        #endregion

    }
}
